package com.tfos.study.entity;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.tfos.study.serializers.CustomeJackSon;
import lombok.Data;
import lombok.ToString;

import java.util.Date;

/**
 * 类功能说明：机构管理实体类 <br/>
 * 公司名称：TF（腾飞）开源 <br/>
 * 作者：luorongxi <br/>
 */
@Data
@ToString
public class Organization {

    /**
     * 机构id
     */
    private Integer orgId;

    /**
     * 机构名称
     */
    private String orgName;

    /**
     * 联系电话
     */
    private String phone;

    /**
     * 邮箱地址
     */
    private String email;

    /**
     * 机构简介
     */
    private String orgIntroduce;

    /**
     * 成员人数
     */
    private Integer memberNumber;

    /**
     * 平均薪水
     */
    private double averageSalary;

    /**
     * 成立时间
     */
    private Date foundTime;

    @JsonCreator
    public Organization(@JsonProperty("orgId") Integer orgId, @JsonProperty("orgName") String orgName, @JsonProperty("phone") String phone,
                        @JsonProperty("email") String email, @JsonProperty("orgIntroduce") String orgIntroduce, @JsonProperty("memberNumber") Integer memberNumber,
                        @JsonProperty("averageSalary") double averageSalary, @JsonProperty("foundTime") Date foundTime) {
        super();
        this.orgId = orgId;
        this.orgName = orgName;
        this.phone = phone;
        this.email = email;
        this.orgIntroduce = orgIntroduce;
        this.memberNumber = memberNumber;
        this.averageSalary = averageSalary;
        this.foundTime = foundTime;
    }

    /**
     * 序列化指定格式的double格式
     */
    @JsonSerialize(using = CustomeJackSon.TfosSerializer.class)
    public double getAverageSalary() {
        return averageSalary;
    }

    /**
     * 反序列化一个固定格式的Date
     */
    @JsonDeserialize(using = CustomeJackSon.TfosDeserializer.class)
    public void setBirthday(Date foundTime) {
        this.foundTime = foundTime;
    }


}
